/**************************************************************************
 * Name         : PVRVDA.h
 * Title        : MVED1 Video Decode Acceleration API
 * Author       : Jason Rogers
 * Created      : 19/11/04
 *
 * Copyright   : 2004 by Imagination Technologies. All rights reserved.
 *             : No part of this software, either material or conceptual 
 *             : may be copied or distributed, transmitted, transcribed,
 *             : stored in a retrieval system or translated into any 
 *             : human or computer language in any form by any means,
 *             : electronic, mechanical, manual or other-wise, or 
 *             : disclosed to third parties without the express written
 *             : permission of Imagination Technologies Limited, Unit 8,
 *             : HomePark Industrial Estate, King's Langley, Hertfordshire,
 *             : WD4 8LZ, U.K.
 *
 * Description  : MVED1 Video Decode Acceleration API
 *
 * Platform     : 
 *

 Version	 	: $Revision: 1.10 $ 

 Modifications	:
 $Log: PVRVDA.h,v $

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

  --- Revision Logs Removed --- 

 */

#ifndef _PVRVDA_H_
#define _PVRVDA_H_

/****************************************************************************/
/*********** External Interface for the PVR video acceleration API **********/
/****************************************************************************/

#include "img_types.h"
#include "PVRCodecAPI.h"


typedef struct BUFFER_TAG*		PVR_BUFFER;


/*****************************************************************************/
/******************************* Defines *************************************/
/*****************************************************************************/

typedef enum {

	PVRVDA_DECODER_DATA,
	PVRVDA_DEBLOCKER_DATA,

} PVRVDA_BUFFERTYPE;

typedef enum
{
	PVRVDA_Y,
	PVRVDA_U,
	PVRVDA_V,
} PVRVDA_COMPONENT;

#define CORE_FEATURE_MPEG_MC		0x00000001
#define CORE_FEATURE_MPEG_IDCT		0x00000002
#define CORE_FEATURE_H264_MC		0x00000010
#define CORE_FEATURE_H264_IT		0x00000020
#define CORE_FEATURE_H264_DB		0x00000040
#define CORE_FEATURE_CSC			0x00000100
#define CORE_FEATURE_INTERM_BUFF	0x00000200

#ifdef __cplusplus
extern "C" {  
#endif

/*****************************************************************************/
/**************************  Function Prototypes *****************************/
/*****************************************************************************/


/********************************************************* Buffer Management */


/***********************************************************************************
 Function Name      : PVRVDAGetCmdBuffer
 Inputs             : hInstance,eBufferType
 Outputs            : pui32BufferSize,phBuffer,ppvAddress
 Returns            : PVRRC
 Description        : Retrieves a buffer from the buffer pool
 ************************************************************************************/
PVRRC PVRCODEC_API PVRVDAGetCmdBuffer(/*in */ PVR_INSTANCE	hInstance, 
							/*in */ PVRVDA_BUFFERTYPE	eBufferType,
							/*out*/ IMG_UINT32			*pui32BufferSize,
							/*out*/ PVR_BUFFER			*phBuffer,
							/*out*/ IMG_PVOID			*ppvAddress);

typedef PVRRC (*fnPVRVDAGetCmdBuffer)(/*in */ PVR_INSTANCE	hInstance, 
							/*in */ PVRVDA_BUFFERTYPE	eBufferType,
							/*out*/ IMG_UINT32			*pui32BufferSize,
							/*out*/ PVR_BUFFER			*phBuffer,
							/*out*/ IMG_PVOID			*ppvAddress);

/***********************************************************************************
 Function Name      : PVRVDACmdBufferRelease
 Inputs             : hInstance,hBuffer
 Outputs            : 
 Returns            : PVRRC
 Description        : Returns the buffer to the buffer pool
 ************************************************************************************/
PVRRC PVRCODEC_API PVRVDACmdBufferRelease(	/*in */ PVR_INSTANCE	hInstance,
											/*in */ PVR_BUFFER 		hBuffer);

typedef PVRRC (*fnPVRVDACmdBufferRelease)(	/*in */ PVR_INSTANCE	hInstance,
											/*in */ PVR_BUFFER 		hBuffer);

/***********************************************************************************
 Function Name      : PVRVDACmdBufferSync
 Inputs             : hInstance,hBuffer,bWait
 Outputs            : 
 Returns            : PVRRC
 Description        : Sync on the last opperation on the buffer
 ************************************************************************************/
PVRRC PVRCODEC_API  PVRVDACmdBufferSync(/*in */PVR_INSTANCE hInstance,
										/*in */PVR_BUFFER 		hBuffer,
										/*in */IMG_BOOL 		bWait);

typedef PVRRC (*fnPVRVDACmdBufferSync)(/*in */PVR_INSTANCE hInstance,
										/*in */PVR_BUFFER 		hBuffer,
										/*in */IMG_BOOL 		bWait);

/***************************************************** Decode APIs */


/***********************************************************************************
 Function Name      : PVRVDADecodeBegin
 Inputs             : hInstance,hDestFrame,pui32Attrib
 Outputs            : 
 Returns            : PVRRC
 Description        : Marks the begining of a frame decode for the given surface.
 ************************************************************************************/
PVRRC PVRCODEC_API PVRVDADecodeBegin(	/*in */ PVR_INSTANCE	hInstance,
										/*in */ PVR_SURFACE		hDestFrame,
										/*in */ IMG_UINT32		pui32Attrib);	

typedef PVRRC (*fnPVRVDADecodeBegin)(	/*in */ PVR_INSTANCE	hInstance,
										/*in */ PVR_SURFACE		hDestFrame,
										/*in */ IMG_UINT32		pui32Attrib);
								  
/***********************************************************************************
 Function Name      : PVRVDADecodeEnd
 Inputs             : hInstance,hDestFrame
 Outputs            : 
 Returns            : PVRRC
 Description        : Marks the end of a decode.
 ************************************************************************************/
PVRRC PVRCODEC_API PVRVDADecodeEnd(/*in */ PVR_INSTANCE hInstance);

typedef PVRRC (*fnPVRVDADecodeEnd)(/*in */ PVR_INSTANCE hInstance);

/***********************************************************************************
 Function Name      : PVRVDADecodeProcessCmds
 Inputs             : hInstance,hBuffer,ui32CmdCount
 Outputs            : 
 Returns            : PVRRC
 Description        : Issues a buffer of commands to decoder.
						The buffer will be returned to the buffer pool when compleate.
 ************************************************************************************/
PVRRC PVRCODEC_API PVRVDADecodeProcessCmds(	/*in */ PVR_INSTANCE hInstance, 
											/*in */ PVR_BUFFER		hBuffer,
											/*in */ IMG_UINT32		ui32CmdCount);

typedef PVRRC (*fnPVRVDADecodeProcessCmds)(	/*in */ PVR_INSTANCE hInstance, 
											/*in */ PVR_BUFFER		hBuffer,
											/*in */ IMG_UINT32		ui32CmdCount);

/***********************************************************************************
 Function Name      : PVRVDASetReferenceFrame
 Inputs             : hInstance,ui32FrameNo,hSurface
 Outputs            : 
 Returns            : PVRRC
 Description        : Sets the given surface as a reference frame.
 ************************************************************************************/
PVRRC PVRCODEC_API PVRVDASetReferenceFrame(	/*in */ PVR_INSTANCE hInstance,
											/*in */ IMG_UINT32 ui32FrameNo, 
											/*in*/  PVR_SURFACE hSurface);

typedef PVRRC (*fnPVRVDASetReferenceFrame)(	/*in */ PVR_INSTANCE hInstance,
											/*in */ IMG_UINT32 ui32FrameNo, 
											/*in*/  PVR_SURFACE hSurface);
/***********************************************************************************
 Function Name      : PVRVDAWriteBlock
 Inputs             : hInstance,hDestSurf,eColourComponent,ui32DestX,ui32DestY
						ui32Width,ui32Height,pSourcePixels,ui32SourceStride,bWait
 Outputs            : 
 Returns            : PVRRC
 Description        : Writes a block of pixels to an unlocked surface.
 ************************************************************************************/
PVRRC PVRCODEC_API PVRVDAWriteBlock(/*in */	PVR_INSTANCE 	hInstance,
									/*in */	PVR_SURFACE			hDestSurf,
									/*in */ PVRVDA_COMPONENT 	eColourComponent,
									/*in */	IMG_UINT32			ui32DestX,
									/*in */ IMG_UINT32			ui32DestY,
									/*in */	IMG_UINT32			ui32Width,
									/*in */	IMG_UINT32			ui32Height,
									/*in */ const IMG_UINT8* 	pSourcePixels,
									/*in */ IMG_UINT32			ui32SourceStride ,
									/*in */ IMG_BOOL			bWait );

typedef PVRRC (*fnPVRVDAWriteBlock)(/*in */	PVR_INSTANCE 	hInstance,
									/*in */	PVR_SURFACE			hDestSurf,
									/*in */ PVRVDA_COMPONENT 	eColourComponent,
									/*in */	IMG_UINT32			ui32DestX,
									/*in */ IMG_UINT32			ui32DestY,
									/*in */	IMG_UINT32			ui32Width,
									/*in */	IMG_UINT32			ui32Height,
									/*in */ const IMG_UINT8* 	pSourcePixels,
									/*in */ IMG_UINT32			ui32SourceStride ,
									/*in */ IMG_BOOL			bWait );

/************************************************* Deblocker APIs */

/***********************************************************************************
 Function Name      : PVRVDADeblockBegin
 Inputs             : hInstance,hFrameSurf
 Outputs            : 
 Returns            : PVRRC
 Description        : Marks the begining of frame deblock for the given surface.
 ************************************************************************************/
PVRRC PVRCODEC_API PVRVDADeblockBegin(	/*in */ PVR_INSTANCE	hInstance,
										/*in */ PVR_SURFACE		hFrameSurf );								   

typedef PVRRC (*fnPVRVDADeblockBegin)(	/*in */ PVR_INSTANCE	hInstance,
										/*in */ PVR_SURFACE		hFrameSurf );	

/***********************************************************************************
 Function Name      : PVRVDADeblockEnd
 Inputs             : hInstance
 Outputs            : 
 Returns            : PVRRC
 Description        : Marks the end of frame deblock.
 ************************************************************************************/
PVRRC PVRCODEC_API PVRVDADeblockEnd(/*in */ PVR_INSTANCE hInstance);

typedef PVRRC (*fnPVRVDADeblockEnd)(/*in */ PVR_INSTANCE hInstance);
/***********************************************************************************
 Function Name      : PVRVDADeblockProcessCmds
 Inputs             : hInstance,hBuffer,ui32CmdCount
 Outputs            : 
 Returns            : PVRRC
 Description        : Issues a buffer of commands to deblocker.
						The buffer will be returned to the buffer pool when compleate.
 ************************************************************************************/
PVRRC PVRCODEC_API PVRVDADeblockProcessCmds(/*in */ PVR_INSTANCE	hInstance, 
											/*in */ PVR_BUFFER			hBuffer,
											/*in */ IMG_UINT32			ui32CmdCount);

typedef PVRRC (*fnPVRVDADeblockProcessCmds)(/*in */ PVR_INSTANCE	hInstance, 
											/*in */ PVR_BUFFER			hBuffer,
											/*in */ IMG_UINT32			ui32CmdCount);

/***********************************************************************************
 Function Name      : PVRVDAGetCoreCapabilities
 Inputs             : hInstance
 Outputs            : pui32BitMask
 Returns            : PVRRC
 Description        : Returns a bit mask with the decode features available on core so
						the application	knows how much processing is carried out in 
						the HW.
 ************************************************************************************/
PVRRC PVRCODEC_API PVRVDAGetCoreCapabilities(	/*in */ PVR_INSTANCE	hInstance, 
												/*out*/ IMG_UINT32*		pui32BitMask);

typedef PVRRC (*fnPVRVDAGetCoreCapabilities)(	/*in */ PVR_INSTANCE	hInstance, 
												/*out*/ IMG_UINT32*		pui32BitMask);

typedef struct
{
	fnPVRInitialise				PVRInitialise;
	fnPVRDeinitialise			PVRDeinitialise;
	fnPVRSurfaceAllocate		PVRSurfaceAllocate;
	fnPVRSurfaceAllocateRaw		PVRSurfaceAllocateRaw;
	fnPVRSurfaceSync			PVRSurfaceSync;
	fnPVRSurfaceLock			PVRSurfaceLock;
	fnPVRSurfaceUnlock			PVRSurfaceUnlock;
	fnPVRSurfaceFree			PVRSurfaceFree;

	fnPVRVDAGetCmdBuffer		PVRVDAGetCmdBuffer;
	fnPVRVDACmdBufferRelease	PVRVDACmdBufferRelease;
	fnPVRVDACmdBufferSync		PVRVDACmdBufferSync;

	fnPVRVDADecodeBegin			PVRVDADecodeBegin;
	fnPVRVDADecodeEnd			PVRVDADecodeEnd;
	fnPVRVDADecodeProcessCmds	PVRVDADecodeProcessCmds;
	fnPVRVDASetReferenceFrame	PVRVDASetReferenceFrame;

	fnPVRVDAWriteBlock			PVRVDAWriteBlock;

	fnPVRVDADeblockBegin		PVRVDADeblockBegin;
	fnPVRVDADeblockEnd			PVRVDADeblockEnd;
	fnPVRVDADeblockProcessCmds	PVRVDADeblockProcessCmds;
	fnPVRVDAGetCoreCapabilities	PVRVDAGetCoreCapabilities;

} PVRVDAAPI;

#ifdef __cplusplus
}
#endif


#endif /* _PVRVDA_H_ */
